Skip to content

โšก LLM Inference Optimization โ€” Notes โ€‹

๐Ÿ“บ Source

Notes from the YouTube course Inference Optimization: From First Principles to Production by Mani Khanuja (The Agentic Enterprise). 29 episodes, covering Modules 0 โ€“ 7.

Training is buying the car. Inference is the taxi meter โ€” it starts with your first user and never stops.


๐Ÿงญ The whole course on one page โ€‹


๐ŸŽ›๏ธ The two rules that hold everything together โ€‹

1. You can optimize only two of three โ€‹

They're one budget, not three separate goals. Push latency down and you serve fewer users per GPU, so cost goes up. Pack more users in and everyone waits longer.

2. Every technique pulls one of four levers โ€‹

LeverExamples in this course
๐Ÿ“ฆ Move fewer bytesQuantization, GQA/MLA, KV-cache compression, FlashAttention
๐Ÿงฎ Do fewer calculationsSparse attention, sliding windows, prefix caching
๐Ÿค Share work across requestsBatching, continuous batching, prefix caching, copy-on-write
๐Ÿ”€ Overlap workChunked prefill, FlashAttention 3 ping-pong, API/engine process split

๐Ÿ’ธ Why it matters โ€” DeepSeek's real meter (Feb 2025)

One day of production cost $87,072. At their list R1 pricing the same tokens would have been worth more than 6ร— that (DeepSeek themselves call this figure theoretical). Engineering closes most of that gap. Pricing doesn't.


๐Ÿ“š Chapters โ€‹

#ChapterEpisodes
0๐Ÿš• Orientation & the request map00 โ€“ 01
1๐Ÿ›ฃ๏ธ Request lifecycle, metrics & benchmarking02 โ€“ 07
2๐Ÿงฑ The two walls: compute vs memory08 โ€“ 13, 17
3๐Ÿ”ญ Observability: what to measure14 โ€“ 16
4๐Ÿงบ Batching & scheduling18 โ€“ 21
5๐Ÿง  Attention: the architecture side22 โ€“ 24
6โš™๏ธ Attention: the kernel side25 โ€“ 27
7๐Ÿ”ข Quantization & numerics28

๐Ÿฉบ The master diagnosis tree โ€‹

Start from the symptom, then find the cause:

๐Ÿง  The one number the course leans on

Arithmetic intensity (FLOPs per byte moved) vs the GPU's ridge point. If you remember one idea, remember this one โ†’ Chapter 2.

<<>> with โ™ฅ๏ธ by S@Nchit